# Maintainer: Alexey Pavlov <alexpux@gmail.com>
# Contributor: AlexWMF <alexxwmf@gmail.com>

_realname=liblastfm
pkgbase=mingw-w64-${_realname}-qt4
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}-qt4"
pkgver=1.0.9
pkgrel=1
pkgdesc="A Qt C++ library for the Last.fm webservices https://www.last.fm (mingw-w64)"
arch=('any')
license=('Boost')
url="https://www.rasterbar.com/products/libtorrent"
conflicts=("${MINGW_PACKAGE_PREFIX}-${_realname}")
depends=("${MINGW_PACKAGE_PREFIX}-qt4"
         "${MINGW_PACKAGE_PREFIX}-fftw"
         "${MINGW_PACKAGE_PREFIX}-libsamplerate")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc"
             "${MINGW_PACKAGE_PREFIX}-cmake")
options=(!strip staticlibs !buildflags)
source=(${_realname}-${pkgver}.tar.gz::"https://github.com/lastfm/liblastfm/archive/${pkgver}.tar.gz"
        versioned-dlls-mingw.patch)
sha256sums=('5276b5fe00932479ce6fe370ba3213f3ab842d70a7d55e4bead6e26738425f7b'
            '8a19f0a53277be5929411f3f247bc5d2c380c32b170ba0d0824bce9b7f7b7fa7')

prepare() {
  cd ${srcdir}/${_realname}-${pkgver}
  patch -p0 -i ${srcdir}/versioned-dlls-mingw.patch
}

build() {
  mkdir ${srcdir}/build-${MINGW_CHOST}
  cd ${srcdir}/build-${MINGW_CHOST}

  MSYS2_ARG_CONV_EXCL="-DCMAKE_INSTALL_PREFIX=" \
  ${MINGW_PREFIX}/bin/cmake \
    -G"MSYS Makefiles" \
    -DCMAKE_INSTALL_PREFIX=${MINGW_PREFIX} \
    -DCMAKE_BUILD_TYPE=RelWithDebInfo \
    -DBUILD_TESTS=False \
    ${srcdir}/${_realname}-${pkgver}

  make ${MAKEFLAGS} # VERBOSE=1
}

package() {
  cd ${srcdir}/build-${MINGW_CHOST}
  make DESTDIR=${pkgdir} -j1 install
}
